<?php
/**
 * Created by PhpStorm.
 * User: 13469
 * Date: 2018/12/12
 * Time: 13:56
 */
include "config.php";
if($_SERVER["REQUEST_METHOD"]=="POST"){
    if(isset($_REQUEST["u_id"])&&isset($_REQUEST["c_id"])&&isset($_REQUEST["num"])){
        $UID=$_REQUEST["u_id"];
        $CID=$_REQUEST["c_id"];
        $CNUM=$_REQUEST["num"];
        $sql="UPDATE carts SET c_num=?,c_total=c_num*c_price WHERE u_id=? AND g_id=?";
        $stmt=$conn->prepare($sql);
        $stmt->bind_param("iii",$CNUM,$UID,$CID);
        $stmt->execute();
        if($stmt->affected_rows>=1){
            print_r(json_encode(array("status"=>1,"msg"=>"修改成功")));
        }else{
            print_r(json_encode(array("status"=>-1,"msg"=>"修改失败")));
        }
    }
}